<template>
  <div class="newslist">
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
        <!-- 路由传值 -->
        <router-link :to="'/home/newsinfo/'+item.id">
          <!-- v-bind:src -->
          <img class="mui-media-object mui-pull-left" :src="item.img_url">
          <div class="mui-media-body">
            <h1 class="titles">{{item.title}}</h1>
            <p class="mui-ellipsis">
              <span>发表时间:{{item.add_time | dataFormat}}</span>
              <span>点击次数:{{item.click}}</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
var start = new Date().toLocaleString();
export default {
  data() {
    return {
      time: start,
      newslist: null
    };
  },
  created() {
    this.getnewslist();
  },
  methods: {
    getnewslist() {
      this.$http
        .get("http://www.liulongbin.top:3005/api/getnewslist")
        .then(result => {
          var result = result.body;
          if (result.status == 0) {
            this.newslist = result.message;
          } else {
            Toast("加载失败");
          }
          //   console.log(result);
        });
    }
  }
};
</script>
<style scoped>
/* .newslist {
  overflow-x: hidden;
} */
.mui-table-view-cell p {
  color: blue;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.titles {
  font-size: 12px;
  /* overflow: hidden; */
}
</style>
